package domain.parsers;

import java.io.IOException;
import java.io.InputStreamReader;

public class LL1Reader {
	private int _currentChar;
	private InputStreamReader _isr;
	private int _actualLine;
	private int _actualColumn;
	
	public LL1Reader(InputStreamReader isr) throws IOException{
		_isr = isr;
		_currentChar = readNext();
		_actualLine = 1;
		_actualColumn = 1;
	}
	
	
	public int getCurrentChar(){
		return _currentChar;
	}
	
	public int readNext() throws IOException{
		int charRead = _isr.read();
		_actualColumn ++;
		if((charRead==10)||(charRead==13)){
			_actualLine++;
		}
		boolean flag = false;
		while(charRead==32 || charRead==9){
			charRead = _isr.read();
			_actualColumn ++;
			flag = true;
		}
		if(flag && (charRead==10)||(charRead==13)){
			_actualLine++;
		}
		_currentChar = charRead;
		return _currentChar;
	}
	
	
	public int actualLine(){
		return _actualLine;
	}
	
	public int actualColumn(){
		return _actualColumn;
	}
	
}
